﻿using HCQ2_Common;
using HCQ2_Model.ViewModel;
using HCQ2_Model.VR.Params;
using HCQ2_Model.VRDD.InputDto._0531;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace HCQ2UI_Logic.DocumentController
{
    /// <summary>
    ///  创始人、用户消息
    /// </summary>
    public class VRPartnerController: BaseLogic
    {
        //***************************1.0 创始人申请列表*******************************
        #region 1.0 默认首次进入创始人界面 + ActionResult DocList()
        /// <summary>
        ///  默认首次进入创始人界面
        /// </summary>
        /// <returns></returns>
        [HCQ2_Common.Attributes.Load]
        [HCQ2_Common.Attributes.Element]
        [HttpGet]
        public ActionResult ApplyList()
        {
            return View();
        }
        #endregion

        #region 1.1 初始化Table + ActionResult InitTable()
        /// <summary>
        ///  初始化Table
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult InitApplyTable()
        {
            int applyStatus = RequestHelper.GetIntByName("applyStatus"),
                page = RequestHelper.GetIntByName("page"),
                rows = RequestHelper.GetIntByName("rows");
            int total = 0;
            var list = operateContext.bllSession.T_VRFounderApply.GetUserMessageList(applyStatus,page,rows, out total);
            TableModel tModel = new TableModel()
            {
                total = total,
                rows = list
            };
            return Json(tModel, JsonRequestBehavior.AllowGet);
        }
        #endregion

        //***************************2.0 创始人列表*******************************
        #region 2.0 默认首次进入创始人列表 + ActionResult DocList()
        /// <summary>
        ///  默认首次进入创始人列表
        /// </summary>
        /// <returns></returns>
        [HCQ2_Common.Attributes.Load]
        [HCQ2_Common.Attributes.Element]
        [HttpGet]
        public ActionResult List()
        {
            return View();
        }
        #endregion

        #region 1.1 初始化Table + ActionResult InitTable()
        /// <summary>
        ///  初始化Table
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult InitTable()
        {
            int applyStatus = RequestHelper.GetIntByName("applyStatus"),
                page = RequestHelper.GetIntByName("page"),
                rows = RequestHelper.GetIntByName("rows");
            int total = 0;
            var list = operateContext.bllSession.T_VRFounderApply.GetUserMessageList(applyStatus, page, rows, out total);
            TableModel tModel = new TableModel()
            {
                total = total,
                rows = list
            };
            return Json(tModel, JsonRequestBehavior.AllowGet);
        }
        #endregion
       
        //***************************3.0 消息列表*******************************
        #region 2.0 默认首次进入创始人列表 + ActionResult DocList()
        /// <summary>
        ///  默认首次进入创始人列表
        /// </summary>
        /// <returns></returns>
        [HCQ2_Common.Attributes.Load]
        [HCQ2_Common.Attributes.Element]
        [HttpGet]
        public ActionResult MessageList()
        {
            return View();
        }
        #endregion

        #region 1.1 初始化消息列表 + ActionResult InitMessageTable(UserMessageQuery param)
        /// <summary>
        ///  初始化消息列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult InitMessageTable(UserMessageQuery param)
        {
            int total = 0;
            var list = operateContext.bllSession.T_VRUserMessage.GetUserMessageList(param, out total);
            TableModel tModel = new TableModel()
            {
                total = total,
                rows = list
            };
            return Json(tModel, JsonRequestBehavior.AllowGet);
        }
        #endregion

        //***************************4.0 度度圈*******************************
        #region 4.0 默认首次进入度度圈用户管理 + ActionResult CircleList()
        /// <summary>
        ///  默认首次进入度度圈用户管理
        /// </summary>
        /// <returns></returns>
        [HCQ2_Common.Attributes.Load]
        [HCQ2_Common.Attributes.Element]
        [HttpGet]
        public ActionResult CircleList()
        {
            return View();
        }
        #endregion

        #region 4.1 初始化度度圈用户列表 + ActionResult InitCircleTable(InputCircleUser param)
        /// <summary>
        ///  初始化用户列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult InitCircleTable(InputCircleUser param)
        {
            int total = 0;
            var list = operateContext.bllSession.DD_User.GetCircleList(param, out total);
            TableModel tModel = new TableModel()
            {
                total = total,
                rows = list
            };
            return Json(tModel, JsonRequestBehavior.AllowGet);
        }
        #endregion

        #region 4.2 设置/取消VIP + ActionResult EditUserType()
        /// <summary>
        ///  设置/取消VIP
        /// </summary>
        /// <param name="user">用户对象</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult EditUserType()
        {
            int user_type = RequestHelper.GetIntByName("user_type");//用户类别
            string userid = RequestHelper.GetStrByName("userid");//用户id数据
            if(string.IsNullOrEmpty(userid))
                return operateContext.RedirectAjax(1, "用户数据不能为空！", "", "");
            operateContext.bllSession.DD_User.ModifyUserType(user_type, userid);
            return operateContext.RedirectAjax(0, "修改人员类别成功~", "", "");
        }
        #endregion
    }
}